import inquirer from 'inquirer';
import { getRoot , createNginxConfigFile } from './utils.js';
import vueConfig from '../../vue.config.js';
const questions = [
  {
    type : 'input',
    name : 'port',
    message : '生成nginx配置文件监听的端口号：',
    default : 8080
  },
  {
    type : 'input',
    name : 'address',
    message : '部署打包的web文件地址：',
    default : '/home/html/xxx/dist/'
  }
]

;(async () => {
  const answers = await inquirer.prompt(questions);
  const rootDir = getRoot('../../');
  let options = Object.assign({} , answers);
  // 读取代理配置
  const proxy = vueConfig.devServer?.proxy || {};
  options = Object.assign({} , options , {proxy});
  createNginxConfigFile(rootDir , options);
})();